package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.RecruitPlanItem;
import cn.wolfcode.crm.domain.Stock;
import cn.wolfcode.crm.mapper.StockMapper;
import cn.wolfcode.crm.qo.PageResult;
import cn.wolfcode.crm.qo.QueryObject;
import cn.wolfcode.crm.qo.StockBillObject;
import cn.wolfcode.crm.service.IStockService;
import cn.wolfcode.crm.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("stock")
public class StockController {
    @Autowired
    private IStockService stockService;

    //只负责转发到库存页面
    @RequestMapping("view")
    public String view() {
        return "/stock/stock";
    }

    @RequestMapping("selectAll")
    @ResponseBody
    public PageResult selectAll(QueryObject qo){
        return stockService.query(qo);
    }

    @RequestMapping("selectItmesById")
    @ResponseBody
    public PageResult selectItmesById(StockBillObject qo){
        return stockService.selectItmesById(qo);
    }

    @RequestMapping("updateNewNumber")
    @ResponseBody
    public JSONResult updateNewNumber(Stock stock) {
        try {
            stockService.updateNewNumber(stock);
        } catch (Exception e) {
            e.printStackTrace();
            return JSONResult.mark("盘点失败!");
        }
        return JSONResult.success("盘点成功!");
    }
}
